/*
 * @Author: Wanko
 * @Date: 2024-06-16 09:43:39
 * @LastEditors: Wanko
 * @LastEditTime: 2024-06-21 19:54:29
 * @Description:
 */
const router = new (require('@koa/router'))({ prefix: '/cards' })

const { authUser } = require('../middleware/auth.js')
const {
  find,
  findById,
  create,
  update,
  del,
  randoms,
  top,
  unTop,
  like,
  unLike,
  collect,
  unCollect
} = require('../controllers/card')
const { auth } = require('../middleware/auth.js')
router.get('/', authUser, find)
router.post('/', auth, create)
router.get('/randoms', authUser, randoms)

router.put('/top/:id', auth, top)
router.del('/top/:id', auth, unTop)

router.get('/:id', authUser, findById)
router.del('/:id', auth, del)
router.put('/:id', auth, update)

router.put('/:id/like', auth, like)
router.del('/:id/like', auth, unLike)

router.put('/:id/collect', auth, collect)
router.del('/:id/collect', auth, unCollect)

module.exports = router
